//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CBigFile {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CBigFile(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CBigFile obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        throw new UnsupportedOperationException("C++ destructor does not have public access");
      }
      swigCPtr = 0;
    }
  }

  public static CBigFile getInstance() {
    return new CBigFile(nelmiscJNI.CBigFile_getInstance(), false);
  }

  public static void releaseInstance() {
    nelmiscJNI.CBigFile_releaseInstance();
  }

  public boolean add(String sBigFileName, long nOptions) {
    return nelmiscJNI.CBigFile_add(swigCPtr, this, sBigFileName, nOptions);
  }

  public void getBigFilePaths(Vector_String bigFilePaths) {
    nelmiscJNI.CBigFile_getBigFilePaths(swigCPtr, this, Vector_String.getCPtr(bigFilePaths), bigFilePaths);
  }

  public void remove(String sBigFileName) {
    nelmiscJNI.CBigFile_remove(swigCPtr, this, sBigFileName);
  }

  public boolean isBigFileAdded(String sBigFileName) {
    return nelmiscJNI.CBigFile_isBigFileAdded(swigCPtr, this, sBigFileName);
  }

  public String getBigFileName(String sBigFileName) {
    return nelmiscJNI.CBigFile_getBigFileName(swigCPtr, this, sBigFileName);
  }

  public void list(String sBigFileName, Vector_String vAllFiles) {
    nelmiscJNI.CBigFile_list(swigCPtr, this, sBigFileName, Vector_String.getCPtr(vAllFiles), vAllFiles);
  }

  public void removeAll() {
    nelmiscJNI.CBigFile_removeAll(swigCPtr, this);
  }

  public void currentThreadFinished() {
    nelmiscJNI.CBigFile_currentThreadFinished(swigCPtr, this);
  }

  public SWIGTYPE_p_FILE getFile(String sFileName, SWIGTYPE_p_unsigned_int rFileSize, SWIGTYPE_p_unsigned_int rBigFileOffset, SWIGTYPE_p_bool rCacheFileOnOpen, SWIGTYPE_p_bool rAlwaysOpened) {
    long cPtr = nelmiscJNI.CBigFile_getFile(swigCPtr, this, sFileName, SWIGTYPE_p_unsigned_int.getCPtr(rFileSize), SWIGTYPE_p_unsigned_int.getCPtr(rBigFileOffset), SWIGTYPE_p_bool.getCPtr(rCacheFileOnOpen), SWIGTYPE_p_bool.getCPtr(rAlwaysOpened));
    return (cPtr == 0) ? null : new SWIGTYPE_p_FILE(cPtr, false);
  }

  public boolean getFileInfo(String sFileName, SWIGTYPE_p_unsigned_int rFileSize, SWIGTYPE_p_unsigned_int rBigFileOffset) {
    return nelmiscJNI.CBigFile_getFileInfo(swigCPtr, this, sFileName, SWIGTYPE_p_unsigned_int.getCPtr(rFileSize), SWIGTYPE_p_unsigned_int.getCPtr(rBigFileOffset));
  }

  public String getFileNamePtr(String sFileName, String sBigFileName) {
    return nelmiscJNI.CBigFile_getFileNamePtr(swigCPtr, this, sFileName, sBigFileName);
  }

}
